/**
 * Create in 2012-10-21 下午7:03:55.
 */
package kit4j.app.notepad.ui.panel;

import java.awt.Dimension;
import java.awt.Rectangle;

import javax.swing.JPanel;

/**
 * 
 * @author MiniKnife
 *
 */
public class BorderMenuPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	
	private int fixedWidth;
	
	private int fixedHeight;
	
	public BorderMenuPanel() {
		this(-1, -1);
	}

	/**
	 * @param fixedWidth
	 * @param fixedHeight
	 */
	public BorderMenuPanel(int fixedWidth, int fixedHeight) {
		super();
		this.fixedWidth = fixedWidth;
		this.fixedHeight = fixedHeight;
		
		init();
	}
	
	private void init() {
	}

	/**
	 * @see javax.swing.JComponent#getWidth()
	 */
	@Override
	public int getWidth() {
		return fixedWidth == -1 ? super.getWidth() : fixedWidth;
	}
	
	/**
	 * @see javax.swing.JComponent#getHeight()
	 */
	@Override
	public int getHeight() {
		return fixedHeight == -1 ? super.getHeight() : fixedHeight;
	}

	/**
	 * @return the fixedWidth
	 */
	public int getFixedWidth() {
		return fixedWidth;
	}

	/**
	 * @param fixedWidth the fixedWidth to set
	 */
	public void setFixedWidth(int fixedWidth) {
		this.fixedWidth = fixedWidth;
	}

	/**
	 * @return the fixedHeight
	 */
	public int getFixedHeight() {
		return fixedHeight;
	}

	/**
	 * @param fixedHeight the fixedHeight to set
	 */
	public void setFixedHeight(int fixedHeight) {
		this.fixedHeight = fixedHeight;
	}
	
	/**
	 * @see java.awt.Component#getBounds()
	 */
	@Override
	public Rectangle getBounds() {
		return new Rectangle(getX(), getY(), getFixedWidth(), getFixedHeight());
	}
	
	/**
	 * @see java.awt.Component#getSize()
	 */
	@Override
	public Dimension getSize() {
		return new Dimension(getFixedWidth(), getFixedHeight());
	}
	
	/**
	 * @see javax.swing.JComponent#getMaximumSize()
	 */
	@Override
	public Dimension getMaximumSize() {
		return getSize();
	}
	
	/**
	 * @see javax.swing.JComponent#getMinimumSize()
	 */
	@Override
	public Dimension getMinimumSize() {
		return getSize();
	}
	
	/**
	 * @see javax.swing.JComponent#getPreferredSize()
	 */
	@Override
	public Dimension getPreferredSize() {
		return getSize();
	}
}
